#ifndef __CFBASE_H__
#define __CFBASE_H__
class CBaseClassFactory : public IClassFactory
{
public:
    // IUnknown methods
    STDMETHOD(QueryInterface)(REFIID riid, void** ppv);
    STDMETHOD_(ULONG, AddRef)(void)
    {
        return ++m_dwRefs;
    }
    STDMETHOD_(ULONG, Release)(void)
    {
        return (--m_dwRefs == 0) ? delete this, REMOVE_OBJECT, 0 : m_dwRefs;
    }

    // IClassFactory methods
    STDMETHOD(CreateInstance)(IUnknown* pUnkOuter, REFIID riid, void** ppv);
    STDMETHOD(LockServer)(BOOL fLock)
    {
        fLock ? LOCK_SERVER : UNLOCK_SERVER;
        return NOERROR;
    }
    virtual HRESULT Create(IUnknown** ppUnk) = 0;
    CBaseClassFactory() : m_dwRefs(0), m_pIID(NULL)
    {
        ADD_OBJECT;
    }
    const IID* m_pIID;
private:
    ULONG m_dwRefs;
};
#endif //__CFBASE_H__
